﻿namespace ufida.u9.ait.openbp
{
	using System;
	using System.Collections.Generic;
    using System.Diagnostics;
    using System.Text;
    using UFIDA.U9.AIT.OpenAPIBE;
    using UFSoft.UBF.AopFrame;
    using UFSoft.UBF.Business;
    using UFSoft.UBF.Util.Context;

	/// <summary>
	/// AITLogSaveBP partial 
	/// </summary>	
	public partial class AITLogSaveBP 
	{	
		internal BaseStrategy Select()
		{
			return new AITLogSaveBPImpementStrategy();	
		}		
	}
	
	#region  implement strategy	
	/// <summary>
	/// AIT日志保存
	/// 启用RN事务
	/// </summary>	
	internal partial class AITLogSaveBPImpementStrategy : BaseStrategy
	{
		public AITLogSaveBPImpementStrategy() { }

		public override object Do(object obj)
		{						
			AITLogSaveBP bpObj = (AITLogSaveBP)obj;

			if (bpObj.Log == null)
				throw new Exception("参数为空");

			using (ISession session = Session.Open())
			{
				AITLog log = AITLog.Create();
				log.Code = bpObj.Log.Code;
				log.Name= bpObj.Log.Name;
				log.InParm = bpObj.Log.InParm;
				log.OutParm = bpObj.Log.OutParm;
				log.RetCode = bpObj.Log.Retcode;
				log.RetMsg = bpObj.Log.Retmsg;
				log.Url = bpObj.Log.Url;
				log.StartTime = bpObj.Log.StartTime;
				log.EndTime = bpObj.Log.EndTime;
				log.UsedTime=(decimal)(bpObj.Log.StartTime- bpObj.Log.EndTime).TotalMilliseconds;

                session.Commit();
			}

			return null;
		}		
	}

	#endregion
	
	
}